home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcr / pcr4_4.lha / DIST / gc / GCUnixInterface.c < prev    next >
C/C++ Source or Header  |  1991-08-06  |  2KB  |  102 lines

  1. /* begincopyright
  2.   Copyright (c) 1988 Xerox Corporation. All rights reserved.
  3.   Use and copying of this software and preparation of derivative works based
  4.   upon this software are permitted. Any distribution of this software or
  5.   derivative works must comply with all applicable United States export
  6.   control laws. This software is made available AS IS, and Xerox Corporation
  7.   makes no warranty about the software, its performance or its conformity to
  8.   any specification. Any person obtaining a copy of this software is requested
  9.   to send their name and post office or electronic mail address to:
  10.     PCR Coordinator
  11.     Xerox PARC
  12.     3333 Coyote Hill Rd.
  13.     Palo Alto, CA
  14.   endcopyright */
  15.   
  16. # include <xr/GC.h>
  17. # include <xr/ThreadsSharedMem.h>
  18. # include <xr/Threads.h>
  19.  
  20. /*
  21.  * Weiser, Demers, Hauser ???
  22.  * Boehm, March 9, 1990 12:06:57 pm PST 
  23.  */
  24.  
  25.  
  26. valloc_free(ptr)
  27. char *ptr;
  28. {
  29.   XR_valloc_free(ptr);
  30. }
  31.  
  32. char *
  33.   calloc(a, b)
  34. unsigned int a, b;
  35. {
  36.     if ( XR_currThread != NIL ) {
  37.        return (char *)GC_malloc(a * b);
  38.     } else {
  39.        return (char *)XR_AllocSharedSysMem(a*b);
  40.     }
  41. }
  42.  
  43. char *
  44.   malloc(a)
  45. unsigned int a;
  46. {
  47.    if ( XR_currThread != NIL ) {
  48.        /* Should call GC_malloc.  But there was a broken client     */
  49.        /* somewhere in prehistory.                    */
  50.        return (char *)XR_malloc(a);
  51.    } else {
  52.        return (char *)XR_AllocSharedSysMem(a);
  53.    }
  54. }
  55.  
  56. char *
  57.   valloc(a)
  58. unsigned int a;
  59. {
  60.   return (char *)XR_valloc(a);
  61. }
  62.  
  63. char *
  64. realloc(a, b)
  65.      char * a;
  66.      unsigned int b;
  67. {
  68.   if ( a >= GC_heapstart ) {
  69.       return (char *)GC_realloc(a,b);
  70.   } else {
  71.       register char * result;
  72.       
  73.       /* This implementation is pretty bogus, since we dont */
  74.       /* know the size of the old block.  We claim this        */
  75.       /* cannot ever read unmapped memory, however, since   */
  76.       /* the heap follows the system memory area.          */
  77.       /* Hopefully there are no clients of this anyway.        */
  78.       result = malloc(b);
  79.       if (result == 0) return(0);
  80.       bcopy(a, result, b);
  81.       return(result);
  82.   }
  83. }
  84.  
  85. void
  86.   cfree(x)
  87. char *x;
  88. {
  89.   if ( x >= GC_heapstart ) {
  90.       XR_free(x);
  91.   }
  92. }
  93.  
  94. void
  95.   free(x)
  96. char *x;
  97. {
  98.   if ( x >= GC_heapstart ) {
  99.       XR_free(x);
  100.   }
  101. }
  102.